import { dirname } from 'path'
import { fileURLToPath } from 'url'
import * as fs from 'fs'

const __dirname = dirname(fileURLToPath(import.meta.url))


let files = fs.readdirSync(__dirname + '/models');

let js_files = files.filter((f)=>{
    return f.endsWith('.js');
}, files)

let model = {}

for (let f of js_files) {
    console.log(`import model from file ${f}...`)
    let name = f.substring(0, f.length - 3)
    console.log(__dirname + '/models/' + f)
    model[name] = await import('file:///'+__dirname + '\\models\\' + f)
}

export default model